package com.github.kezhenxu94.playground.java.miscellaneous;

import org.junit.Test;

/**
 * Created by com.ikezhenxu.java.study on 6/30/15.
 */
public class UnicodeStuff {

	public static void main(String[] args) {
		char[] c = "中华人民共和国".toCharArray();
		for (int i$ = 0; i$ < c.length; i$++) {
			System.out.println(Character.codePointAt(c, i$));
		}

		char alpha = '\u0391';
		char letterA = '\u0041';
		System.out.printf("%c == %c  %b\n", alpha, letterA, alpha == letterA);
		System.out.println('\u00c1');
		final String AAcute = "\u0041\u0301";
		System.out.println((AAcute + ".length()=" + AAcute.length()));
	}

	@SuppressWarnings("unused")
	@Test
	public void literals() {
		int dadaCafe = 0xDADA_CAFE;
		System.out.println("dadaCafe = " + dadaCafe);
		char a = '\u005C\u0027'; // compile error in intelliJ IDE, but it is
									// right, \u005c is '\', \u0027 is '''
		char \u0041 = '\u005C\u005C'; // compile error in intelliJ IDE, but it
										// is right, \u005c is '\', \u0027 is
										// '''
		System.out.println("a = " + a);
		System.out.println("A = " + A);
		long i1 = 100_0000_0000_0000L;
		int b1 = 0b1101_1011_0110;
		int h1 = 0x7F_FF_FF_FF;
		int h2 = -0x12;
		int h3 = 0xFFFFFFEE;
		int o1 = 010;
		double f1 = .1;
		double f2 = 0x1e2;
		double zero = 0e0; // pass
		double infinite = 1. / 0.;
		double nInfinite = -1. / 0.;
		// int iInfinite = 1 / 0; // runtime error
		// double iInfinite = 1/ 0; // runtim error
		System.out.println("i1 = " + i1);
		System.out.println("b1 = " + b1);
		System.out.println("h1 = " + h1);
		System.out.println("h2 = " + h2);
		System.out.println("h3 = " + h3);
		System.out.println("o1 = " + o1);
		System.out.println("f2 = " + f2);
		System.out.println("zero = " + zero);
		System.out.println("infinite = " + infinite);
		System.out.println("nInfinite = " + nInfinite);

		System.out.println("Float.toHexString ( 123.45 ) = " + Double.toHexString(123.45D));
		double f3 = 0x0.8p0; // p is exponetIndicator like e in decimal format
		System.out.println("f3 = " + f3);
		assert h1 == Integer.MAX_VALUE;
		assert h2 == h3;
	}

	@Test
	public void types() {
		float f1 = 1.2F;
		if ((f1 != 0)) {
		}
		System.out.println(++f1);
	}

	@Test
	public void literals2() {
		int octal19 = '\212';
		System.out.println(octal19);
	}

	@Test

	public void testAssert() {
		assert Character.isDigit('1');
	}
}
